home *** CD-ROM | disk | FTP | other *** search
- #ifndef __presto__stack_h__
- #define __presto__stack_h__
-
- //
- // Stack maintenance
- //
- // Modification History:
- //
- // 05-Dec-89 John Faust
- // Remove all stack free lists. Allocate stacks of fixed size when thread
- // is allocated. Stack remains associated with owning thread. More
- // efficient (removes search of stack freelist for stack of proper size,
- // allocation of stack if one of proper size not found, and eliminates
- // need to balance stack freelists).
- //
- // 16-Nov-1989 John Faust
- // Add support for per-processor stack freelists.
- //
-
- #define MINSTACKSIZEXP (10)
- #define ONEK (1<<10)
- //#define DEFSTACKSIZ (ONEK << 2) /* 4k */
- //#define DEFSTACKSIZ (ONEK << 3) /* 8k */
- #define DEFSTACKSIZ (ONEK << 4) /* 16k */
-
- //
- // Return how many integral chunks of MINSTACKSIZES fit in the
- // requested stacksize
- //
- //#define STACKSIZTOMINCHUNKS(sz) (sz >> MINSTACKSIZEXP)
-
- class Stack {
- int *st_base; // bottom of stack
- int st_size; // what user thinks
- int st_limit; // what we really are
- public:
- Stack(int size);
- inline ~Stack()
- { this->destroy (); }
- inline int size()
- { return st_size; }
- inline int limit()
- { return st_limit;}
- /* XX machdep */
- inline int *top()
- { return (int*)(((int)st_base + st_limit - 4) & ~03);}
- inline void destroy()
- { delete st_base; }
-
- //
- // Disabled. Stacks only built when threads are allocated, and
- // incrementing a counter atomically on the critical path is too slow.
- // Returns -1.
- //
- int numstacksbuilt();
- };
-
-
- #endif /* __presto__stack_h__ */
-